local skel = fk.CreateSkill {
  name = "lb__jiaotu",
}

Fk:loadTranslationTable {
  ["lb__jiaotu"] = "焦土",
  [":lb__jiaotu"] = "出牌阶段限一次，你可弃置一张牌并横置至多体力上限名角色，然后本轮所有横置角色使用的【杀】均视为火【杀】；若你的体力上限为全场最少，你回复1点体力。",

  ["#lb__jiaotu_trigger"] = "焦土",
  ["#lb__jiaotu"] = "焦土：你可以弃置一张牌并横置至多%arg名角色",

  ["$lb__jiaotu1"] = "开始清扫。",
  ["$lb__jiaotu2"] = "行动四，点火。",
}

skel:addEffect("active", {
  prompt = function(self, player, selected_cards, selected_targets)
    return "#lb__jiaotu:::" .. player.maxHp
  end,
  anim_type = "control",
  can_use = function(self, player)
    return player:usedSkillTimes(skel.name, Player.HistoryPhase) == 0
  end,
  card_filter = function(self, player, to_select, selected)
    return #selected == 0 and not player:prohibitDiscard(to_select)
  end,
  target_filter = function(self, player, to_select, selected, selected_cards)
    return #selected < player.maxHp and not to_select.chained
  end,
  feasible = function(self, player, selected, selected_cards, card)
    return #selected_cards == 1 and #selected <= player.maxHp and #selected > 0
  end,
  on_use = function(self, room, effect)
    local player = effect.from
    local tos = effect.tos
    room:sortByAction(tos)
    room:throwCard(effect.cards, skel.name, player, player)
    for _, t in ipairs(tos) do
      t:setChainState(true)
    end
    if table.find(room:getOtherPlayers(player), function(p)
          return p.maxHp < player.maxHp
        end) == nil and player:isWounded() then
      room:recover {
        who = player,
        num = 1,
        recoverBy = player,
        skillName = skel.name
      }
    end
  end,
})

skel:addEffect(fk.AfterCardUseDeclared, {
  is_delay_effect = true,
  mute = true,
  anim_type = "offensive",
  can_trigger = function(self, _, target, player, data)
    return player:hasSkill(skel.name) and player:usedSkillTimes("lb__jiaotu", Player.HistoryRound) > 0 and
        target.chained and data.card.trueName == "slash" and data.card.name ~= "fire__slash"
  end,
  on_use = function(self, event, target, player, data)
    data:changeCard("fire__slash", data.card.suit, data.card.number, skel.name)
  end,
})

return skel
